#define _CRT_SECURE_NO_WARNINGS
#include<vector>
#include<iostream>
using namespace std;
class Solution {
public:
    int numberOfArithmeticSlices(vector<int>& nums) {
        int n = nums.size();
        if (n < 3) return 0;
        vector<int>dp(n);
        int sum = 0;
        int ret = 0;
        for (int i = 2; i < n; i++) {
            if (nums[i] - nums[i - 1] == nums[i - 1] - nums[i - 2]) {
                int ret1 = nums[i] - nums[i - 1];
                dp[i] = 1;
                int j = i - 3;
                while (j-- >= 0) {
                    if (nums[j + 1] - nums[j] == ret1) dp[i]++;
                }
            }
            sum += dp[i];
        }
        return sum;
    }
};
int main() {
    Solution a;
    vector<int>f(1);
    f[0] = 2;
  int ret=  a.numberOfArithmeticSlices(f);
  cout << ret << endl;
    return 0;
}
class Solution {
public:
    int numberOfArithmeticSlices(vector<int>& nums) {
        int n = nums.size();
        if (n < 3) return 0;
        vector<int>dp(n);
        int sum = 0;
        for (int i = 2; i < n; i++) {
            if (nums[i] - nums[i - 1] == nums[i - 1] - nums[i - 2]) {
                dp[i] = dp[i - 1] + 1;
            }
            sum += dp[i];
        }
        return sum;
    }
};
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int n = nums.size();
        int left = 0;
        int right = 0;
        while (right < n) {
            while (right < n && nums[right] == 0) right++;
            while (left < right && nums[left] != 0) left++;
            if (right < n && left <= right)
                swap(nums[left], nums[right]);
            left++;
            right++;
        }
    }
};
class Solution {
public:
    void moveZeroes(vector<int>& nums) {
        int n = nums.size();
        for (int cur = 0, dest = -1; cur < n; cur++) {
            if (nums[cur])
                swap(nums[cur], nums[++dest]);
        }
    }
};
class Solution {
public:
    void move(vector<int>& arr, int a) {
        int n = arr.size();
        for (int i = n - 1; i > a; i--) {
            arr[i] = arr[i - 1];
        }
    }
    void duplicateZeros(vector<int>& arr) {
        int n = arr.size();
        for (int i = 0; i < n; i++) {
            if (arr[i] == 0 && i + 1 < n) {
                move(arr, i + 1);
                arr[i + 1] = 0;
                i++;
            }
        }
    }
};
class Solution {
public:
    void duplicateZeros(vector<int>& arr) {
        int n = arr.size();
        int i = 0;
        int sum = 0;
        for (i = 0; i < n; i++) {
            if (arr[i] == 0) sum += 2;
            else sum++;
            if (sum >= n) break;
        }
        int end1 = i;
        int end2 = n - 1;
        if (sum == n + 1) {
            arr[n - 1] = 0;
            end1--;
            end2--;
        }
        for (; end1 >= 0; end1--, end2--) {
            if (arr[end1] != 0) {
                arr[end2] = arr[end1];
            }
            else {
                arr[end2--] = 0;
                arr[end2] = 0;
            }
        }
    }
};
class Solution {
public:
    int deal(int n) {
        int sum = 0;
        int i = n;
        while (i != 0) {
            sum += (i % 10) * (i % 10);
            i /= 10;
        }
        return sum;
    }
    bool isHappy(int n) {
        int slow = deal(n);
        int fast = deal(slow);

        while (slow != fast) {
            slow = deal(slow);
            fast = deal(fast);
            fast = deal(fast);
        }
        if (slow == 1) return true;
        return false;
    }
};
class Solution {
public:
    int maxArea(vector<int>& height) {
        int n = height.size();
        int tmax = 0;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                tmax = max(tmax, (j - i) * min(height[i], height[j]));
            }
        }
        return tmax;
    }
};
class Solution {
public:
    int maxArea(vector<int>& h) {
        int n = h.size();
        int left = 0;
        int right = n - 1;
        int tmax = 0;
        while (left < right) {
            tmax = max(tmax, (right - left) * min(h[left], h[right]));
            if (h[left] < h[right]) left++;
            else right--;
        }
        return tmax;
    }
};
class Solution {
public:
    int triangleNumber(vector<int>& nums) {
        int n = nums.size();
        if (n < 3)return 0;
        vector<int>f(n);
        int a = 0;
        int b = 0;
        while (a < n) {
            if (nums[a] != 0)f[b++] = nums[a++];
        }
        int sum = 0;
        for (int i = 0; i < b; i++) {
            for (int j = i + 1; j < b; j++) {
                for (int k = j + 1; k < b; k++) {
                    if (f[i] + f[j] > f[k] && f[j] + f[k] > f[i] && f[i] + f[k] > f[j]) sum++;
                }
            }
        }
        return sum;
    }
};
void Sort(vector<int>& nums, int n) {
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            if (nums[i] > nums[j]) swap(nums[i], nums[j]);
        }
    }
}
class Solution {
public:

    int triangleNumber(vector<int>& nums) {
        int n = nums.size();
        vector<int>f(n);
        int a = 0;
        int b = 0;
        while (a < n) {
            if (nums[a] != 0)f[b++] = nums[a++];
            else a++;
        }
        n = b;
        if (n < 3)return 0;
        Sort(f, n);
        int sum = 0;
        for (int i = n - 1; i >= 2; i--) {
            int left = 0;
            int right = i - 1;
            while (left < right) {
                if (f[left] + f[right] > f[i])
                {
                    sum += (right - left);
                    right--;
                }
                else {
                    left++;
                }
            }
        }
        return sum;
    };
};
class Solution {
public:
    vector<int> FindNumbersWithSum(vector<int> arr, int sum) {
        int n = arr.size();
        int a = 0;
        int b = n - 1;
        while (a < b) {
            if (arr[a] + arr[b] < sum) a++;
            else if (arr[a] + arr[b] > sum) b--;
            else return { arr[a],arr[b] };

        }
        vector<int>f(0);
        return f;
    }
};